#pragma once
#include <IceUtil\Shared.h>
#include <IceUtil\Handle.h>
#include "IXRequestJob.h"
#include "XRequestReaderThread.h"

namespace Xts
{
	namespace Util
	{
		class XProducerConsumer : public ::IceUtil::Shared
		{
		public:
			XProducerConsumer(void);
			~XProducerConsumer(void);

			bool IsRunning()const{ return x_bIsRunning; }
			void StartReaderThreads(unsigned int n);
			void StopReaderThreads();
			void NewRequestJob(const IXRequestJobPtr& pJob);

		protected:
			XRequestQueuePtr x_pJobQueue;
			::std::vector<::IceUtil::ThreadControl> x_JobReaderThreadCtrlSet;
			bool x_bIsRunning;
		};
		typedef ::IceUtil::Handle<XProducerConsumer> XProducerConsumerPtr;
	}
}


